<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of pagination
 *
 * @author IT
 */
class pagination extends connection{
    function phan_trang($sobai){
        $per_page = 2;
        //first
        $firt = 1;
        echo $trang2 ='<li><a class="'.'first'.'" href="index.php?page='.$firt.'">'.'First'.'</a></li>';
        //page
        for($i = 1;$i<= ceil($sobai/$per_page);$i++){
        $trang = '<li>' . '<a href="index.php?page=' . $i . '">' . $i . '</a></li>';
        echo $trang;
        }
        //next
        $page1;$next;
        if(isset($_GET['page'])==NULL){
            $page1 = 1;
        }  else {
            $page1 = $_GET['page'];
        }
        $next =$page1+1;
        if($next > ceil($sobai/$per_page)){
            $next = ceil($sobai/$per_page);
        }
        echo $trang3 ='<li><a class="'.'next'.'" href="index.php?page='.$next.'">'.'Next'.'</a></li>';
        //last
        for($i=1;$i<ceil($sobai/$per_page);$i++){
            $last = $i+1;
            if ($last <= ceil($sobai/$per_page)){
                $trang1 ='<li><a class="'.'last'.'" href="index.php?page='.$last.'">'.'Last'.'</a></li>';
            }
        }
        echo $trang1;
        
    }
}